package com.trabalho1.db;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ConnectionFactory 
{
    public static Connection getConnection() 
    {
        try 
        {
            //Class.forName("com.mysql.jdbc.Driver");
            Class.forName("org.postgresql.Driver");            
        } 
        catch (ClassNotFoundException ex) 
        {
            Logger.getLogger(ConnectionFactory.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        System.out.println("Conectando ao banco");
        
        try 
        {
            //return DriverManager.getConnection("jdbc:mysql://localhost:3306/exercicio", "root", "");
            return DriverManager.getConnection("jdbc:postgresql://localhost:5432/trabalho1_java_web", "gsguma", "12345");
        } 
        catch(SQLException e) 
        {
            throw new RuntimeException(e);
        }
    }
}
